package com.effectivcrm.thymeleaf.extension;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import com.effectivcrm.domain.ui.Validation;

@Component
public class EmailValidatorOutputStrategy implements ValidatorOutputStrategy {
	
	private final String NAME = "notempty";
	
	@Override
	public boolean canHandle(Validation validation) {
		return StringUtils.equalsIgnoreCase(NAME, validation.getName());
	}

	@Override
	public void handle(Validation validation, Map<String,String> modAttrValMap) {
		
		modAttrValMap.put("data-bv-notempty", "true");
		modAttrValMap.put("data-bv-notempty-message", validation.getMessage());
		
	}

}
